<template>
  <view class="reformCard" @click="toApproveDetail">
    <view class="cardItem top">
      <view class="name"
        >{{ msg.buildingName + "-" + msg.elevatorAddress }}
        <text class="tag">维修</text>
      </view>
      <view class="status" :style="{color:passMap[msg.status].color}">{{ passMap[msg.status].text }}
        <uni-icons type="arrowright" :color="passMap[msg.status].color"></uni-icons>
      </view>
    </view>
    <view class="time cardItem">{{ msg.createTime}}</view>
    <view class="cardItem" v-if="showStatus">
      <view class="label">维修进度:</view>
      <view class="statusTag" :style="{color:statusMap[msg.status].color,
        borderColor:statusMap[msg.status].color
      }">{{statusMap[msg.status].text }}</view>
    </view>
    <view class="cardItem">
      <view class="label">报障状态：</view>
      <view class="desc">{{
        msg.elevatorStop == 1 ? "正常运行" : "停梯"
      }}</view>
    </view>
    <view class="cardItem" v-if="msg.problemItemNames">
      <view class="label">故障现象：</view>
      <view class="desc">{{
        msg.elevatorStop == 1 ? "正常运行" : "停梯"
      }}</view>
    </view>
    <view class="cardItem" v-if="partsNames">
      <view class="label">配件部件：</view>
      <view class="desc">{{ partsNames }}</view>
    </view>
    <view class="cardItem">
      <view class="label">报障单位: </view>
      <view class="desc">{{ msg.faultCompany }}</view>
    </view>
    <view class="cardItem">
      <view class="label">报障人: </view>
      <view class="desc">{{ msg.createUserName }}</view>
    </view>
  </view>
</template>

<script>
export default {
	props: {
		msg: {
			type: Object,
		},
	},
	computed: {
		partsNames() {
			if (this.msg.partNames == null) {
				return '';
			} else {
				return this.msg.partNames.split('&amp;&amp;').join('>');
			}
		},
		// 只有审核通过才有维修状态
		showStatus() {
			return this.msg.status == 2 || this.msg.status == 3 || this.msg.status == 4;
		}
	},
	data() {
		return {
			passMap: {
				0: {
					text: '待指派',
					color: '#FA6400',
				},
				1: {
					text: '待审核',
					color: '#FA6400',
				},
				2: {
					text: '审核通过',
					color: '#16BF99',
				},
				3: {
					text: '审核通过',
					color: '#16BF99',
				},
				4: {
					text: '审核通过',
					color: '#16BF99',
				},
				5: {
					text: '已撤回',
					color: '#999999',
				},
				6: {
					text: '审核不通过',
					color: '#E02020',
				},
				7: {
					text: '审核通过',
					color: '#E02020',
				},
			},
			statusMap: {
      
				1: {
					text: '待处理',
					color: '#FA6400',
				},
				2: {
					text: '待开始',
					color: '#E02020',
				},
				3: {
					text: '维修中',
					color: '#0091FF',
				},
				4: {
					text: '已完成',
					color: '#999',
				},
				7:{
					text: '已关闭',
					color: '#999',
				}
        
			},
      
		};
	},
	methods:{
		toApproveDetail() {
			console.log(this.msg);
			uni.navigateTo({
				url:
          '/subpages/approve/repairDetail?planId=' +
          this.msg.planId +
          '&elevatorId=' +
          this.msg.elevatorId +
          '&businessApproveId=' +
          this.msg.businessApproveId +
          '&myApply=' +
          1,
			});
		}
	}
};
</script>

<style lang="scss" scoped>
@import "./card.scss";
// .reformCard{
//     background: #fff;
//     border-radius: 8rpx;
//     margin-bottom: 16rpx;
//     box-shadow: 16rpx;
//     padding:  16rpx;
//   .cardItem{
//     display: flex;
//     .tag{

//     }
//   }
//   .top{
//     justify-content: space-between;
//   }
// }
</style>
